#!/usr/bin/python
# coding: utf-8

import sys
import optparse

MAX_PW_SIZE = 30


def main(pw_type=None):

    for line in sys.stdin:
        line = line.strip()
        if not line:
            print '-2'
            continue
        if pw_type:
            pathways = []
            for pt in line.split('\t'):
                for p in pt.split('|'):
                    t,p = p.split(' ', 1)
                    if t == pw_type:
                        pathways.append( [tuple(map(int,i.split(':'))) for i in p.strip().split()] )
            pathways.sort(key=lambda p: p[0][1])
            if not pathways:
                print '-2'
                continue
        else:
            pathways = sorted([[tuple(map(int,i.split(':'))) for i in p.split()] for p in line.split('\t')], key=lambda p: p[0][1])

        min_pathway = pathways[0]
        pw_size = min_pathway[0][1]
        if pw_size > MAX_PW_SIZE + 1:
            print '-1'
            continue
        if len(min_pathway) == 1:
            print '-3'
            continue


        ##
        ## распределение доли пути от числа мест
        ##
        res = []
        i,j = 0,0
        for i in range(pw_size*2+2):
            if i == min_pathway[j][0]:
                cur = min_pathway[j][1]
                if len(min_pathway) - 1 > j:
                    j += 1
            if i > 0:
                res.append( 1.0 - float(cur)/pw_size )
        
        #print ' '.join('%.3f' % i for i in res)
        #print min_pathway
        print '%s\t%f\t%f' % (pw_size, res[pw_size], res[pw_size*2])

if __name__ == "__main__":
   
    from optparse import OptionParser
    parser = OptionParser()
    parser.add_option("-t", "--type", dest="type")
    (options, args) = parser.parse_args()
    

    main( options.type  )

